//
//  WaterFallScrollView.h
//  瀑布流1
//
//  Created by yuanyuan on 15-3-9.
//  Copyright (c) 2015年 hanjiaxue. All rights reserved.
//

#import <UIKit/UIKit.h>

//
//  YYWaterflowView.h
//  06-瀑布流
//
//  Created by apple on 14-7-29.
//  Copyright (c) 2014年 wendingding. All rights reserved.
//

#import <UIKit/UIKit.h>

//使用瀑布流形式展示内容的控件
typedef enum {
    YYWaterflowViewMarginTypeTop,
    YYWaterflowViewMarginTypeBottom,
    YYWaterflowViewMarginTypeLeft,
    YYWaterflowViewMarginTypeRight,
    YYWaterflowViewMarginTypeColumn,//每一列
    YYWaterflowViewMarginTypeRow,//每一行
    
}YYWaterflowViewMarginType;

@class WaterFallScrollView,WaterFallViewCell;

/**
 *  1.数据源方法
 */
@protocol YYWaterflowViewDataSource <NSObject>
//要求强制实现
@required
/**
 * （1）一共有多少个数据
 */
-(NSUInteger)numberOfCellsInWaterflowView:(WaterFallScrollView *)waterflowView;
/**
 *  (2)返回index位置对应的cell
 */
-(WaterFallViewCell *)waterflowView:(WaterFallScrollView *)waterflowView cellAtIndex:(NSUInteger)index;

//不要求强制实现
@optional
/**
 *  (3)一共有多少列
 */
-(NSUInteger)numberOfColumnsInWaterflowView:(WaterFallScrollView *)waterflowView;

@end


/**
 *  2.代理方法
 */
@protocol YYWaterflowViewDelegate <UIScrollViewDelegate>
//不要求强制实现
@optional
/**
 *  (1)第index位置cell对应的高度
 */
-(CGFloat)waterflowView:(WaterFallScrollView *)waterflowView heightAtIndex:(NSUInteger)index;
/**
 *  (2)选中第index位置的cell
 */
-(void)waterflowView:(WaterFallScrollView *)waterflowView didSelectAtIndex:(NSUInteger)index;
/**
 *  (3)返回间距
 */
-(CGFloat)waterflowView:(WaterFallScrollView *)waterflowView marginForType:(YYWaterflowViewMarginType)type;
@end


/**
 *  3.瀑布流控件
 */

@interface WaterFallScrollView : UIScrollView

/**
 *  (1)数据源
 */
@property(nonatomic,weak)id<YYWaterflowViewDataSource> dadaSource;
/**
 *  (2)代理
 */
@property(nonatomic,weak)id<YYWaterflowViewDelegate> delegate;

#pragma mark-公共方法
/*
 *cell的宽度
 */
-(CGFloat)cellWidth;
/**
 *  刷新数据
 */
-(void)reloadData;
/**
 *  根据标识去缓存池中查找可循环利用的cell
 */
- (id)dequeueReusableCellWithIdentifier:(NSString *)identifier;



/**
 *  所有cell的frame数据
 */
@property(nonatomic,strong)NSMutableArray *cellFrames;
/**
 *  正在展示的cell
 */
@property(nonatomic,strong)NSMutableDictionary  *displayingCells;
/**
 *  缓存池（使用SET）
 */
@property(nonatomic,strong)NSMutableSet *reusableCells;










@end
